/**
 * 
 */
package com.bagtrack.model;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.codehaus.jackson.annotate.JsonIgnore;


/**
 * @author Brian Boyle
 * Nov 13, 2011
 *
 */
@Entity
@Table(name = "ROUTE")
public class Route {

    private Long id;
    private String name;
    private Double averageTime;
    private List<Waypoint> waypoints;
    private Gate gate;
    private List<Job> jobs;

    /**
     * @param name
     * @param averageTime
     */
    public Route(String name, Double averageTime) {
        this.name = name;
        this.averageTime = averageTime;
    }

    /**
     * Default Constructor
     */
    public Route() {

    }

    /**
     * @return the id
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "ID")
    public Long getId() {
        return id;
    }


    /**
     * @param id the id to set
     */
    public void setId(Long id) {
        this.id = id;
    }


    /**
     * @return the name
     */
    @Column(name = "NAME")
    public String getName() {
        return name;
    }


    /**
     * @param name the name to set
     */
    public void setName(String name) {
        this.name = name;
    }


    /**
     * @return the averageTime
     */
    @Column(name = "AVG_TIME")
    public Double getAverageTime() {
        return averageTime;
    }


    /**
     * @param averageTime the averageTime to set
     */
    public void setAverageTime(Double averageTime) {
        this.averageTime = averageTime;
    }


    /**
     * @return the waypoints
     */
    @OneToMany(mappedBy = "route", fetch = FetchType.LAZY)
    @JsonIgnore
    public List<Waypoint> getWaypoints() {
        return waypoints;
    }


    /**
     * @param waypoints the waypoints to set
     */
    public void setWaypoints(List<Waypoint> waypoints) {
        this.waypoints = waypoints;
    }


    /**
     * @return the jobs
     */
    @OneToMany(mappedBy = "route", fetch = FetchType.LAZY)
    @JsonIgnore
    public List<Job> getJobs() {
        return jobs;
    }


    /**
     * @param jobs the jobs to set
     */
    public void setJobs(List<Job> jobs) {
        this.jobs = jobs;
    }

    /* (non-Javadoc)
     * @see java.lang.Object#toString()
     */
    @Override
    public String toString() {
        return "Route [id=" + id + ", name=" + name + ", averageTime=" + averageTime + "]";
    }
}
